Set objFileSys = CreateObject("Scripting.FileSystemObject")

CreateRootVDir "Src\Contoso\Contoso.WebSite", "contoso"
CreateRootVDir "Src\Fabrikam\Fabrikam.WebSite", "fabrikam"
CreateRootVDir "Src\Litware\Litware.WebSite", "litware"
CreateRootVDir "Src\EmptyVD", "litwarehr"
CreateRootVDir "Src\EmptyVD", "services.litwarehr"

CreateServiceVDir "Src\Litware\LitwareHR.Authorization.SvcHost", "Authorization"
CreateServiceVDir "Src\Litware\LitwareHR.Authentication.SvcHost", "Authentication"
CreateServiceVDir "Src\Litware\LitwareHR.Portfolio.SecureHost", "SecureHost"
CreateServiceVDir "Src\Litware\LitwareHR.Portfolio.UnSecureHost", "UnSecureHost"

Sub CreateServiceVDir(vDirPath, vDirName)
    Set Root = GetObject("IIS://LocalHost/W3SVC/1/ROOT/services.litwarehr")
    CreateVDir Root,vDirPath, vDirName
End Sub

Sub CreateRootVDir(vDirPath, vDirName)
    Set Root = GetObject("IIS://LocalHost/W3SVC/1/ROOT")
    CreateVDir Root,vDirPath, vDirName
End Sub

Sub CreateVDir(Root,vDirPath, vDirName)
    Set Dir = Root.Create("IIsWebVirtualDir", vDirName)
    
    Dir.Path = objFileSys.GetAbsolutePathName("..\..\..\.") & "\" & vDirPath
    Dir.AppCreate2(2)
    Dir.AppFriendlyName = vDirName
    Dir.AuthFlags = 5
    Dir.EnableDefaultDoc = True
    Dir.DefaultDoc = "default.htm,default.aspx,default.asp"
    Dir.DirBrowseFlags = &H4000003E ' date, time, size, extension, longdate
    Dir.AccessFlags = 513 ' read, script
    
    Dir.SetInfo
End sub

